/****************************************************************************
*                                                                           *
*  Modified version of NiHandTracker program                                *
*  Copyright (C) 2011 PrimeSense Ltd.                                       *
*                                                                           *
****************************************************************************/
//---------------------------------------------------------------------------
// Includes
//---------------------------------------------------------------------------
#include <XnCppWrapper.h>
#include "NiHandViewer.h"
#include "ChordCircle.h"
#include "MidiPlayer.h"


//---------------------------------------------------------------------------
// Defines
//---------------------------------------------------------------------------
#define SAMPLE_XML_PATH "./Config.xml"
//"../../Data/SamplesConfig.xml"


//---------------------------------------------------------------------------
// Globals
//---------------------------------------------------------------------------
xn::Context		g_context;
xn::ScriptNode	g_scriptNode;


int main(int argc, char* argv[])
{
	XnStatus				rc;
	xn::EnumerationErrors	errors;

	// Create a context with default settings
	rc = g_context.InitFromXmlFile(SAMPLE_XML_PATH, g_scriptNode, &errors);
	if (rc == XN_STATUS_NO_NODE_PRESENT)
	{
		XnChar strError[1024];
		errors.ToString(strError, 1024);
		printf("%s\n", strError);
		return (rc);
	}
	else if (rc != XN_STATUS_OK)
	{
		printf("Open failed: %s\n", xnGetStatusString(rc));
		return (rc);
	}

	SimpleViewer& viewer = HandViewer::CreateInstance(g_context);

	rc = viewer.Init(argc, argv);
	if (rc != XN_STATUS_OK)
	{
		printf("Viewer init failed: %s\n", xnGetStatusString(rc));
		return 1;
	}

	rc = viewer.Run();
	if (rc != XN_STATUS_OK)
	{
		printf("Viewer run failed: %s\n", xnGetStatusString(rc));
		return 1;
	}

	return 0;
}








/*

//Old kinect control code

#include "KinectControl.h"
#include <iostream>
using namespace std;

int main( int argc, char** argv )
{
	KinectControl xKinectControl;
	if( xKinectControl.Create() == XN_STATUS_OK )
	{
		// set LED
		xKinectControl.SetLED( KinectControl::LED_RED );

		// Move motor
		xKinectControl.Move( 5 );

		// get value
		int iA;
		KinectControl::MOTOR_STATUS eStatus;
		XnVector3D vVec;
		xKinectControl.GetInformation( iA, eStatus, vVec );

		cout << "Angle: " << iA << endl;
		cout << "Motor Status:" << eStatus <<  endl;
		cout << "Acc Vector: " << vVec.X << "/" << vVec.Y << "/" << vVec.Z << endl;
	}
	xKinectControl.Release();
}
*/